package cn.zswltech.gruul.web.api.controller;

import cn.zswltech.gruul.api.DictionaryApi;
import cn.zswltech.gruul.biz.service.DictionaryService;
import cn.zswltech.gruul.common.result.Response;
import cn.zswltech.gruul.common.entity.DictionaryDO;
import cn.zswltech.gruul.common.dal.query.DictionaryQuery;
import cn.zswltech.gruul.common.dal.tkmybatis.Page;
import cn.zswltech.gruul.common.dal.vo.DictionarySave;
import cn.zswltech.gruul.web.api.controller.common.BaseController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class DictionaryController extends BaseController implements DictionaryApi {

    @Resource(name = "dictionaryServiceAPI")
    private DictionaryService dictionaryService;

    /**
     * 查询字典配置列表
     *
     * @return
     */
    @Override
    public Response<Page<DictionarySave>> getDictionaryList(DictionaryQuery query) {
        return dictionaryService.getDictionaryList(query);
    }

    /**
     * 查询字典不分页
     *
     * @return
     */
    @Override
    public Response<List<DictionaryDO>> getDictionaryListNoPage(DictionaryQuery query) {
        return dictionaryService.getDictionaryListNoPage(query);
    }

    /**
     * 新建字典配置
     *
     * @param dictionarySave
     * @return
     *
     */
    @Override
    public Response createDictionary(DictionarySave dictionarySave) {

        return dictionaryService.createDictionary(dictionarySave);
    }

    /**
     * 编辑字典配置
     *
     * @param dictionarySave
     * @return
     * @
     */
    @Override
    public Response updateDictionary(DictionarySave dictionarySave) {
        return dictionaryService.updateDictionary(dictionarySave);
    }

    /**
     * 删除字典配置
     *
     * @param myKey
     * @return
     * @
     */
    @Override
    public Response deleteDictionary(String myKey) {
        return dictionaryService.deleteDictionary(myKey);
    }
}
